<template>
  <el-select v-bind="selectProps" v-on="selectEvents">
    <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
    <!-- 插槽内容 -->
    <template v-for="(_, slot) in $slots" #[slot]="scope">
      <slot :name="slot" v-bind="scope || {}"></slot>
    </template>
  </el-select>
</template>

<script lang="ts">
import { defineComponent, PropType } from 'vue';

interface Option {
  label: string;
  value: string | number;
}

export default defineComponent({
  name: 'BSelect',
  props: {
    options: {
      type: Array as PropType<Option[]>,
      required: true
    },
    selectProps: {
      type: Object as PropType<Record<string, any>>,
      default: () => ({})
    },
    selectEvents: {
      type: Object as PropType<Record<string, any>>,
      default: () => ({})
    }
  }
});
</script>
